 
 
insert overwrite table jms_dm.dm_repair_access_sum_dt partition (dt) 
select 
      t.scan_network_code       --维修点编码
     ,t.scan_network_name       --维修点名称
     ,sum(case when t.scan_type_code='07' then 1 else 0 end )  as  total_in_num            --入库数量
     ,sum(case when t.scan_type_code='07' and  is_damage = '0' then 1 else 0 end )  as  damage_num --未仲裁上报数量
     ,sum(case when t.scan_type_code='34' then 1 else 0 end )  as  total_out_num  --出库数量
     ,sum(case when t.scan_type_code='34' and  dw_operate = '1' then 1 else 0 end )  as  center_num  --中心入库数量	
     ,sum(case when t.scan_type_code='11' then 1 else 0 end )  as  total_off_num   --报废数量
     ,t.dt as date_time
     ,t.dt as dt 
from jms_dm.dm_repair_access_detail_dt t
where t.dt between  date_add('{{ execution_date  | cst_ds }}', -15) and '{{ execution_date  | cst_ds }}'
group by 
      t.scan_network_code       --维修点编码
     ,t.scan_network_name       --维修点名称
     ,t.dt
  distribute by pmod(hash(rand()), 20)
  ;

